/**
* ...
* @author Default
* @version 0.1
*/

package bdz.cms.vo{
	import flash.net.URLVariables;
	import flash.utils.Dictionary;

	public class MediaVO {
		public var id:Number;
		public var type:String;
		public var location:String;
		public var category:Number;
		public var meta:Dictionary;
		public var order:Number;
		public function MediaVO(xm:* = null) {
			if(xm is XML){
				id = Number(xm.media_id);
				type = xm.media_type;
				location = xm.media_location;
				category = Number(xm.cat_id);
				order  = Number(xm.order);
				try{
					if (xm.meta) {
						parseMeta(xm.meta.child("*"));
					}
				}catch(e:Error){
					
				}
				
			}
		}
		private function parseMeta(xlist:XMLList):void {
			meta = new Dictionary();			
			for each(var xm:XML in xlist) {
				var nme:String = xm.name().localName;
				meta[nme] = {};
				meta[nme].id = xm.@id;
				meta[nme].value = xm;
			}
		}
		public function addMeta(key:String, value:*, mid:Number = -1):void{
			if(meta == null){
				meta = new Dictionary();
			}
			if(meta[key] == null){
				meta[key] = {};
			}
			if(mid != -1 && meta[key].id == null){
				meta[key].id = mid
			}
			meta[key].value = value;
		}
		
	}
}
	